﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace PhysicsSimulator
{
    class VectorHelper
    {
        public static Vector2 RotateVector(float angle, Vector2 v)
        {
            Vector2 r = Vector2.Zero;
            r.X = v.X * (float)Math.Cos(angle) - v.Y * (float)Math.Sin(angle);
            r.Y = v.X * (float)Math.Sin(angle) + v.Y * (float)Math.Cos(angle);
            return r;
        }

        public static Vector2 RotatePoint(float angle, Vector2 A, Vector2 O)
        {
            Vector2 B = Vector2.Zero;

            Vector2 OA = Vector2.Subtract(A, O);
            Vector2 OB = RotateVector(angle, OA);

            B = Vector2.Add(OB, O);

            return B;
        }
    }
}
